package controller

import (
	"github.com/dchest/captcha"
	"github.com/kataras/iris/v12"
)

const (
	StdWidth  = 108
	StdHeight = 36
)

func GetCaptchaImg(ctx iris.Context) {
	captcha.Server(StdWidth, StdHeight).
		ServeHTTP(ctx.ResponseWriter(), ctx.Request())
}

func GetCaptchaId(ctx iris.Context) {
	// Bind: {{.CaptchaId}} with "Hello world!"
	cap := captcha.NewLen(4)
	// log.Print("Debug cap:", cap)
	ctx.ViewData("CaptchaId", cap)
	// Render template file: ./views/hello.html
	ctx.View("login.html")
}
